<?php
require_once 'BaseController.php';

/**
 * 物件リクエスト入力画面コントローラクラス<br />
 *
 * @package apamanshop
 * @author A.Miyata
 * @copyright　
 */
class Inquiry_RequestentryController extends Inquiry_BaseController
{
	/**
	 * インデックスアクション
	 *
     * @access public
     * @return void
	 */
	public function indexAction()
	{
		$this->setMainTemplate('cms_search2.tpl');
        //表示テンプレートパス設定
        $this->_display_path = APPLICATION_PATH . '/modules/inquiry/views/scripts/estate.tpl';

		// パラメータの取得
		//$this->_params = $this->getParameters();

		//=====表示用共通パラメータ設定=====
		$this->_data =  $this->_params;
		$this->setCommonParams();
		$this->setSubParams();

		//DB問合せ：ご希望の検索条件一覧取得
	    $loader = new Zend_Application_Module_Autoloader(array(
			'namespace' => 'Rstobi',
			'basePath' => APPLICATION_PATH . '/modules/rstobi',
		));
		$this->_model = new Rstobi_Model_SearchDisplay();

		//検索条件（地域・沿線）の反映
		$this->_model->getSearchConditionChiikiEnsen($this->_params,$this->_data);
		$this->_data['condDsp'] = str_replace('<span class="spot">都道府県(市区町村)：</span>', "", $this->_data['condition1']);
		$this->_data['condDsp'] = str_replace('<span class="spot">沿線・駅：</span>', "", $this->_data['condDsp']);
		$this->_data['condDsp'] = str_replace('<span class="spot">物件の最寄り駅：</span>', "", $this->_data['condDsp']);
		$this->_data['condDsp'] = str_replace('<span class="spot">キーワード：</span>', "", $this->_data['condDsp']);

		//検索条件（基本条件）の反映
		$this->_model->getSearchConditionKihon($this->_params,$this->_data);
		//検索条件（こだわり条件）の反映
		$this->_model->getSearchConditionKodawari($this->_params,$this->_data);

	    $this->_model_requesttenpo = new Search_Model_Requesttenpo();

	    //API仕様に合わせるためパラメータ格納用の配列を準備して取得する。
		//更にSrhKbnを変換する。(SrhType=1 → 01 SrchType=2 → 02)
	    $tmpdata = $this->_params;
		if($tmpdata['SrhType'] == Apm_Config_Search::SRHTYPE_JYUSYO){
			$tmpdata['SrhKbn'] = Apm_Config_Search::SRHKBN_JYUSYO;
			$this->_data['SrhTypeNm'] = '地域';
		}else{
			$tmpdata['SrhKbn'] = Apm_Config_Search::SRHKBN_ENSENEKI;
			$this->_data['SrhTypeNm'] = '駅';
		}
		$this->_data['requestTenpo'] = $this->_model_requesttenpo->getRequestTenpoSearch($tmpdata);
		$this->_data['SelectedShop'] = $this->_params['SelectedShop'];

		// 北海道の場合、周辺の店舗のデフォルトチェックを外す
		if (in_array('01', $this->_data['PrefCd'])) {
			$this->_data['area_check_off'] = 1;
		}

		//===キャンペーン情報取得===
        $this->setCampaignParams("2, 4", 1);

        // hiddenタグ生成
        $excludes = array('NameSei','NameMei','Mail','Tel1','Tel2','Tel3','Fax1','Fax2','Fax3','Comment','NeedTimeKbn','SelectedShop','condDsp','Name','Tel','Fax','TimeStr');
        $this->_data['hiddenTag'] = Apm_Util::generateHiddenTag($this->_params,$excludes);

		//=====ブロック設定=====
		$this->setBlockRequestScript();
		$this->setSubblockHpCommon();
		$this->setBlock($this->_requestentry_easy_helper);

        //=====表示=====
        $this->display($this->_display_path);
	}

	/**
	 * 物件リクエスト画面共通パラメータ設定
	 *
	 */
	private function setSubParams()
	{
		//=====タイトル=====
		$this->setTitle('賃貸情報アパマンショップ[おまかせ物件リクエスト]');

		//=====フッタのトップへ戻るコメント=====
		$this->_data['footerTitle'] = 'おまかせ物件リクエストページ';

		//=====タイトルバー設定=====
		$this->_data['contentsTitle'] = 'おまかせ物件リクエスト　≫　お客様情報の入力';

		// ======手順画像========
		if ($this->_params['EasyRequest'] === '1') {
			$this->_data['step_image'] = '';
			$return_url = $this->_baseurl.'search/easyrequest/';
			if ($this->_params['SrhType'] == '1') $return_url .= 'jusyo/';
			$this->_data['return_url'] = $return_url;
		} else {
			if ($this->_params['SrhType']== Apm_Config_Search::SRHTYPE_JYUSYO){
				$this->_data['step_image'] = '/images/step_b03_03.gif';
			}else if($this->_params['SrhType'] == Apm_Config_Search::SRHTYPE_ENSENEKI){
				$this->_data['step_image'] = '/images/step_b02_04.gif';
			}		
			$this->_data['return_url'] = $this->_baseurl.'search/requestsearch/jyoken/';
		}
		
		$this->addMetaCss('/css/valuable.css',array('type' => 'text/css','media' => 'all'));
		$this->addMetaCss('/css/easyrequest01.css',array('type' => 'text/css','media' => 'all'));

        $this->_breadcrumb->add('お客様情報の入力', $this->_sslurl . 'inquiry/requestentry');
        $this->setBreadCrumb($this->_breadcrumb->generateBreadcrumb());
	}

}
?>
